/*
 * UnaryAteOperatorAst.cpp
 *
 *  Created on: 1 Nov 2010
 *      Author: ph1109
 */

#include <MAlice/Ast/UnaryAteOperatorAst.h>
#include <MAlice/Ast/IntegerLiteralAst.h>
#include <MAlice/Ast/BinaryAddOperatorAst.h>
#include <MAlice/Ast/AssignmentOperatorAst.h>
#include <MAlice/Parser/location.hh>

namespace MAlice
{

UnaryAteOperatorAst::UnaryAteOperatorAst(location loc, VariableAst* lhs) :
	UnaryOperatorAst(loc, "ate", lhs)
{
	MALICE_TRACE;
}

UnaryAteOperatorAst::~UnaryAteOperatorAst()
{
	MALICE_TRACE;
}

llvm::Value* UnaryAteOperatorAst::generate()
{
	MALICE_TRACE;
	return AssignmentOperatorAst(mLocation,
			reinterpret_cast<VariableAst*> (getLHS()),
			new BinaryAddOperatorAst(
					mLocation, getLHS(), new IntegerLiteralAst(mLocation, 1))
	).generate();
}

}
